//
//  RootViewController.m
//  zhijian
//
//  Created by lcb on 2019/1/18.
//  Copyright © 2019 lcb. All rights reserved.
//

#import "RootViewController.h"
#import "JMTabBarController.h"
#import "Base.h"
#import "HomeViewController.h"
#import "QuestionViewController.h"
#import "UserViewController.h"
#import "BaseNavigationController.h"
#import "UINavigationController+FullscreenPopGesture.h"
#import "LoginViewController.h"
@interface RootViewController ()
{
}
@property(nonatomic,strong)JMConfig *config;
@property(nonatomic,assign)NSInteger currentIndex;
@end

@implementation RootViewController
- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.view.backgroundColor = [UIColor redColor];
     self.navigationController.navigationBarHidden=YES;
    _currentIndex =0;
    [self initUI];
}
-(void)dealloc
{
    [[JMConfig config] configNormal];
}
-(JMConfig *)config
{
    if(!_config)
    {
        _config = [JMConfig config];
        _config.norTitleColor = UIColorOfHex(0x666666);
        _config.selTitleColor = [UIColor blackColor];
        _config.tabBarBackground = UIColorOfHex(0xffffff);
        _config.isClearTabBarTopLine=NO;
        _config.tabBarTopLineColor = UIColorOfHex(0xdfdfdf);
        _config.imageSize =CGSizeMake(25, 25);
    }
    return _config;
}

-(void)initUI
{
    
    NSMutableArray *titleArr = [NSMutableArray arrayWithObjects:@"对比",@"咨询",@"我的", nil];
    NSMutableArray *imageNormalArr = [NSMutableArray arrayWithObjects:@"tab1_nor",@"tab2_nor",@"tab3_nor", nil];
    NSMutableArray *imageSelectedArr = [NSMutableArray arrayWithObjects:@"tab1_sel",@"tab2_sel",@"tab3_sel", nil];
    NSMutableArray *controllersArr = [NSMutableArray array];
    //
    HomeViewController *homevc = [[HomeViewController alloc] init];
    BaseNavigationController *homenav = [[BaseNavigationController alloc] initWithRootViewController:homevc];
    [controllersArr addObject:homenav];
    //
    QuestionViewController *qusvc = [[QuestionViewController alloc] init];
    BaseNavigationController *qusnav = [[BaseNavigationController alloc] initWithRootViewController:qusvc];
    [controllersArr addObject:qusnav];
    //
    UserViewController *uservc = [[UserViewController alloc] init];
    BaseNavigationController *usernav = [[BaseNavigationController alloc] initWithRootViewController:uservc];
    [controllersArr addObject:usernav];
    
    JMTabBarController *tabBarVc = [[JMTabBarController alloc] initWithTabBarControllers:controllersArr NorImageArr:imageNormalArr SelImageArr:imageSelectedArr TitleArr:titleArr Config:self.config];
    tabBarVc.delegate=self;
    [self.view addSubview:tabBarVc.view];
    [self.view sendSubviewToBack:tabBarVc.view];
}
//-(void)tabBarController:(UITabBarController *)tabBarController didSelectIndex:(NSInteger)selectIndex
//{
////    if (selectIndex==2 && ![[BaseShare sharedBaseShare] isLogin]) {
////        LoginViewController *login =[[LoginViewController alloc] init];
////        [self presentViewController:login animated:YES completion:nil];
////        return;
////    }
////    
//    _currentIndex = selectIndex;
//}

@end
